package com.qiulingcloud.commonsserver.exception;


import com.qiulingcloud.commonsserver.exception.code.BaseResponseCode;

/**
 * @Author：zhangqiang
 * @Description：
 * @Date：Created in 2:46 2020/2/8
 * @Modified By：
 */
public class BusinessException extends RuntimeException {

    /**
     * 异常 code
     */
    private final int code;

    /**
     * 异常提示
     */
    public final String defaultMessage;

    public BusinessException(int code, String defaultMessage) {
        super(defaultMessage);
        this.code = code;
        this.defaultMessage = defaultMessage;
    }

    public BusinessException(BaseResponseCode baseResponseCode) {
        this(baseResponseCode.getCode(), baseResponseCode.getMsg());
    }

    public int getCode() {
        return code;
    }

    public String getDefaultMessage() {
        return defaultMessage;
    }
}
